package com.NeuglsWorkStudio.UI.FormElement.Component
{
	import com.NeuglsWorkStudio.UI.FormElement.Config.TConfig;
	import com.NeuglsWorkStudio.Utility.Utility;
	import com.NeuglsWorkStudio.Utility.nConsts;
	
	import flash.display.BitmapData;
	import flash.filters.DropShadowFilter;
	import flash.geom.Rectangle;
	import flash.text.TextFormat;
	
	public class THorizontalListItem extends TListItem
	{
		public function THorizontalListItem(AConfig:TConfig)
		{
			super(AConfig);
		}
		
		override protected function DrawIconAndLabel():void{
			var LastX:Number=5;
			
			if(_FIcon!=null){
				if(!this.contains(_FIcon))
					this.addChild(_FIcon);
				if(HoverItemConfig().IconDisplayHeight!=0&&HoverItemConfig().IconDisplayWidth!=0&&HoverItemConfig().CenterIcon){
					Utility.ProcessDisplayObjectPosition(HoverItemConfig().IconDisplayWidth,
						HoverItemConfig().IconDisplayHeight,
						_FIcon,nConsts.bpFit);
				}

				_FIcon.x=(HoverItemConfig().Width-_FIcon.width)/2;
				_FIcon.y=(HoverItemConfig().Height-_FIcon.height-_FLabel.height)/2;
			}
			
			var IconH:Number=_FIcon?_FIcon.height+_FIcon.y:0;
			with(_FLabel){
				x=(HoverItemConfig().Width-width)/2;
				y=(HoverItemConfig().Height+IconH-height)/2;
			}
		}
		
		
		override protected function ToDraw(S:int):void{
			var BorderSize:Number=0;
			var BorderColor:int=0xFFFFFF;
			var W:Number=this.HoverItemConfig().Width;
			var H:Number=this.HoverItemConfig().Height;
			var AColor:int;
			var Alpha:Number;
			var FontColor:int;
			switch(S){
				case cNormal:
					AColor=this.HoverItemConfig().NormalBackColor;
					Alpha=this.HoverItemConfig().NormalBackAlpha;
					BorderSize=this.HoverItemConfig().NormalBorderSize;
					BorderColor=this.HoverItemConfig().NormalBorderColor;
					
					FontColor=this.HoverItemConfig().NormalFontColor;
					break;
				case cOver:
					AColor=this.HoverItemConfig().HoverBackColor;
					Alpha=this.HoverItemConfig().HoverBackAlpha;
					BorderSize=this.HoverItemConfig().HoverBorderSize;
					BorderColor=this.HoverItemConfig().HoverBorderColor;
					
					FontColor=this.HoverItemConfig().HoverFontColor;
					break;
				case cDown:
					AColor=this.HoverItemConfig().DownBackColor;
					Alpha=this.HoverItemConfig().DownBackAlpha;
					BorderSize=this.HoverItemConfig().DownBorderSize;
					BorderColor=this.HoverItemConfig().DownBorderColor;
					
					FontColor=this.HoverItemConfig().DownFontColor;
					break;
			}
			
			with(this._FBack.graphics){
				clear();
				beginFill(AColor,Alpha);
				lineStyle(1,BorderColor);
				drawRect(0,0,this.HoverItemConfig().Width,
					this.HoverItemConfig().Height
				);
				endFill();
			}
			
			var textFormat:TextFormat=_FLabel.ATextFormat;
			textFormat.color=FontColor;
			_FLabel.ATextFormat=textFormat;
		}
	}
}